<template>
 <div>
  <h3>Home123</h3>
  <!--子路由组件在这里显示-->
  <!--注意一定要写上内容在router-link中-->
  <router-link to="/home/news">消息</router-link> |
  <router-link to="/home/message">登录</router-link>
  <router-view></router-view>
 </div>
</template>

<script>
export default {
  name: 'Home',
  data(){
    return {
      message: '你好啊',
      path: '/home/news'
    }
  },
  created(){
    console.log("home create");
  },
  destroyed(){
    console.log("home create");
  },
  activated(){
    this.$router.push(this.path).catch(err=>{
      console.log("输出报错");
    });
  },
  beforeRouteLeave(to,from,next){
    console.log(this.$route.path);
    this.path = this.$route.path;
    next();
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
 
</style>
